﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AvansRS.Domain;
using AvansRS.Domain.DataInterface;
using NHibernate;
using NHibernate.Criterion;

namespace AvansRS.Data
{
    public class EventRepository : BaseRepository<Event>, IEventRepository
    {
        public IList<Event> GetEventsForEntity(int id)
        {
            using (ISession session = SessionProvider.GetSession())
            {
                IList<Event> events = session.CreateCriteria(typeof (Event))
                    .CreateCriteria("ApplicableEntities")
                    .Add(Expression.Eq("ID", id))
                    .List<Event>();

                return events;
            }
        }
    }
}
